package com.ruoyi.generator.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.generator.entity.ProjectMonitoring;
import com.ruoyi.generator.service.IProjectMonitoringService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监测预警值数据Controller
 *
 * @author ruoyi
 * @date 2025-09-15
 */
@RestController
@RequestMapping("/monitoring")
public class ProjectMonitoringController extends BaseController
{
    @Autowired
    private IProjectMonitoringService projectMonitoringService;

    /**
     * 查询监测预警值数据列表
     */
    @PreAuthorize("@ss.hasPermi('monitoring:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectMonitoring projectMonitoring)
    {
        startPage();
        List<ProjectMonitoring> list = projectMonitoringService.selectProjectMonitoringList(projectMonitoring);
        return getDataTable(list);
    }

    /**
     * 导出监测预警值数据列表
     */
    @PreAuthorize("@ss.hasPermi('monitoring:export')")
    @Log(title = "监测预警值数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectMonitoring projectMonitoring)
    {
        List<ProjectMonitoring> list = projectMonitoringService.selectProjectMonitoringList(projectMonitoring);
        ExcelUtil<ProjectMonitoring> util = new ExcelUtil<ProjectMonitoring>(ProjectMonitoring.class);
        util.exportExcel(response, list, "监测预警值数据数据");
    }

    /**
     * 获取监测预警值数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('monitoring:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(projectMonitoringService.selectProjectMonitoringById(id));
    }

    /**
     * 新增监测预警值数据
     */
    @PreAuthorize("@ss.hasPermi('monitoring:add')")
    @Log(title = "监测预警值数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectMonitoring projectMonitoring)
    {
        return toAjax(projectMonitoringService.insertProjectMonitoring(projectMonitoring));
    }

    /**
     * 修改监测预警值数据
     */
    @PreAuthorize("@ss.hasPermi('monitoring:edit')")
    @Log(title = "监测预警值数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectMonitoring projectMonitoring)
    {
        return toAjax(projectMonitoringService.updateProjectMonitoring(projectMonitoring));
    }

    /**
     * 删除监测预警值数据
     */
    @PreAuthorize("@ss.hasPermi('monitoring:remove')")
    @Log(title = "监测预警值数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectMonitoringService.deleteProjectMonitoringByIds(ids));
    }
}
